<template>
    <div id="inspection-detail">
        <el-dialog
            :title="titleImgCon"
            v-model="isImgDialog" 
            draggable 
            :close-on-click-modal="false" 
            width="40%" 
            :before-close="handleClose"
            :destroy-on-close="true"
        >
        
            <el-table class="table-s" :data="rectifyList" style="width: 100%" border>
                <el-table-column min-width="270" prop="fileOriginName" :show-overflow-tooltip="true" :label="$t('5l2R6NiV8F5KyemPq8xq')"  align="center" />
                <el-table-column min-width="160" prop="createdTime" :show-overflow-tooltip="true" label="上传时间"  align="center" />
                <el-table-column min-width="120" prop="createdUserName" :show-overflow-tooltip="true" label="上传人"  align="center" />
                <el-table-column min-width="120" :show-overflow-tooltip="true" label="缩略图"  align="center">
                    <template #default="scope">
                        <img style="width: 30px;height: 20px;" :src="pathData + scope.row.path" />
                    </template>
                </el-table-column>
                <el-table-column min-width="120" :show-overflow-tooltip="true" label="操作"  align="center"  fixed="right">
                    <template #default="scope">
                        <el-link target="_blank" :href="pathData + scope.row.path" type="primary">{{ $t('i8A6uFe7Z4rYBFs9LUfm') }}</el-link>
                    </template>
                </el-table-column>
            </el-table>

            <template #footer>
                <el-button @click="cancelUseClick">{{ $t('9YxdWp3OFxHvMW4VGh71') }}</el-button>
            </template>
        </el-dialog>
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, reactive , computed , toRef , toRefs , toRaw , onMounted , watch } from 'vue'
import { FormInstance, FormRules , ElMessage, ElButton, ElCol, ElDatePicker, ElDialog, ElDivider, ElForm, ElFormItem, ElInput, ElOption, ElRadio, ElRow, ElSelect, ElTable, ElTableColumn } from 'element-plus'
import useCurrentInstance from '/@/utils/hook/useCurrentInstance';

/*** 定义接口基础数据类型 */
interface formType {
    ruleForm: any,
}
/*** form 表单数据类型 */
type ruleFormType = {}
export default defineComponent( {
    name: 'inspection-detail',
    components: {},
    props: {
        isImgDialog:{
            type: Boolean,
            default: false,
        },
        imgInfo: {
            type: Array,
            default: []
        },
        titleImgCon: {
            type: String,
            default: ''
        }
    },
    setup(props,ctx){
        const { proxy } = useCurrentInstance();
        const $t = proxy.$t;
        
        const titleImgCon = ref()
        const detailsType = ref('')
        const pathData = ref(import.meta.env.VITE_API_URL + '/') // 获取地址
        const rectifyList: any = ref([])

        /*** state 引用接口定义基础数据初始值 */
        const state = reactive < formType > ({
            ruleForm: {} as ruleFormType
        })

        /*** 截取日期格式方法 */
        const formatDate = (row:any, column:any) => {
          // 获取单元格数据
          let data = row[column.property]
          if(data == $t('utiIUzqSzcKy0QiDc49n')){
            return '-'
          }else{
            return data
          }
        }

        /*** handleClose 关闭按钮点击事件 */
        const handleClose = () => {
            ctx.emit('cancelImgClick')
        }

        /*** cancelUseClick 取消事件 */
        const cancelUseClick = () => {
            ctx.emit('cancelImgClick')
        }
        /*** 监听isImgDialog的变化 */
        watch(() => props.isImgDialog,(newVal) => {
            if(newVal){
                titleImgCon.value = props.titleImgCon
                rectifyList.value = toRaw(props.imgInfo)
            }
        })

        /*** isImgDialog 响应弹窗的关闭  */
        const isImgDialog = computed(() => {
            return props.isImgDialog
        })

        return {
            handleClose,
            cancelUseClick,
            titleImgCon,
            ...toRefs(state),
            isImgDialog,
            detailsType,
            pathData,
            formLabelWidth: '100px',
            formatDate,
            rectifyList,
        }
    },
} )
</script>
<style scoped lang="scss">
    :deep(.el-link__inner){
        color: #0052D9;
    }
    // :deep(.el-divider__text){
    //     color: #303133;
    //     font-weight: bold;
    // }
    .path_look{
        display: block;
        width: 100%;
        border: 1px solid #e4e7ed;
        border-radius: 4px;
        span{
          display: block;
          margin-left: 15px;  
          color: #606266;
        }
    }
    .second-level-detail{
        width: 100%;
        margin: auto;
        padding: 10px;
        border: 1px solid #fcfafa;
        border-radius: 2px;
    }
    .data-detail{
        width: 100%;
        border: 1px solid #fcfafa;
        border-radius: 2px;
        padding: 10px;
    }
    .heightcss{
        max-height: calc(100vh - 750px) !important;
    }
</style>